//
//  TapTabBarItemView.m
//  TapController
//
//  Created by marcus on 11-10-10.
//  Copyright (c) 2011年 wangjun.easymrse.com. All rights reserved.
//

#import "TapTabBarItemView.h"

@implementation TapTabBarItemView
-(void)setTitle:(NSString *)title imageName:(NSString *)imageName tag:(int)tag
{
    [self setTag:tag];
    [self setFrame:CGRectMake(80*tag,0, 80, 48)];
    [self setBackgroundColor:[UIColor clearColor]];
    UIImageView *imageView=[[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]] autorelease];
    [imageView setContentMode:UIViewContentModeScaleAspectFit];
    [imageView setFrame:CGRectMake(21, 0, 38, 38)];
    [self addSubview:imageView];
    
    UILabel *titleLable=[[[UILabel alloc] initWithFrame:CGRectMake(0, 35, 80, 12)] autorelease];
    UIFont* uifont = [UIFont systemFontOfSize:10.0];
	[titleLable setFont:uifont];
    [titleLable setBackgroundColor:[UIColor clearColor] ];
    [titleLable setText:title];
    [titleLable setTextColor:[UIColor whiteColor]];
    [titleLable setTextAlignment:UITextAlignmentCenter];
    [self addSubview:titleLable];
    
    UITapGestureRecognizer *tapGesture=[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapFrom:)] autorelease];
    [self addGestureRecognizer:tapGesture];
    
}
-(void)handleTapFrom:(UIGestureRecognizer *)gesture
{
     [[NSNotificationCenter defaultCenter] postNotificationName:@"change.tabbar.view" object:[NSNumber numberWithInt:self.tag]];
}
-(void)dealloc
{
    [super dealloc];
}
@end
